package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupProgramValues;

/**
 * Denne klasse bruges til at hente al data i bs_program_values og returnere det
 * @author junjie
 */
public abstract class BackupProgramValueHandler {
    
    /**
     * Henter alle rækker i bs_program_values og returnerer et BackupProgramValues[] model
     * @return BackupProgramValues[]
     * @throws SQLException
     * @throws ClassNotFoundException 
     */
    public static BackupProgramValues[] getProgramValues() throws SQLException, ClassNotFoundException
    {
        BackupProgramValues[] programValuesArray = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_program_values", "", "", "", "id", "vat", "environment_tax");
        programValuesArray = new BackupProgramValues[result.length];
        
        db.closeDB();
        
        for(int i = 0; i<result.length; i++){
            programValuesArray[i] = new BackupProgramValues(Integer.parseInt(result[i][0]),Double.parseDouble(result[i][1]),Double.parseDouble(result[i][2]));
        }
        return programValuesArray;
}
}
